package com.joplus.housekeeper.bean;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.joplus.housekeeper.R;

/**
 * Created by ccm on 2016/9/8 11:35
 */
public class CamboMoneyAdapter extends BaseAdapter {
    private CamboMoneyBean bean;
    private Context mContext;
    private TextView tv;
    private LinearLayout ll;
    private int listenerPosition=50;

    public CamboMoneyAdapter(Context context, CamboMoneyBean bean) {
        this.bean = bean;
        this.mContext = context;
    }

    @Override
    public int getCount() {
        return bean.getStoredDTO().getLevelList().size()-1;
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.item_combo_money, null);
        tv = (TextView) convertView.findViewById(R.id.tv_money);
        ll = (LinearLayout) convertView.findViewById(R.id.ll_money);
        tv.setText("￥"+bean.getStoredDTO().getLevelList().get(position+1).getMoney() + "元");
        if (listenerPosition+1 == position+1) {
            tv.setTextColor(Color.parseColor("#E0AC54"));
            ll.setBackgroundResource(R.drawable.shape_gold_coner);

        }
        return convertView;
    }

    public void changeB(int position) {
        this.listenerPosition = position;
        notifyDataSetChanged();
    }
}
